<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="initial-scale=1, user-scalable=0, minimal-ui">
    <title></title>
</head>
<body onload="JsHandler()">
<script type="text/javascript" src="/res/common/js/jquery.js"></script>
<p>
    <input type="button" id="enter" value="我是按钮1" onclick="click1();"
    />
    <input type="button" id="enter" value="我是按钮2" onclick="click2();"
    />
</p><br/>
<p>
    <a href=demo3.html>跳转</a>
</p>
<script>


    var default_data = {
        error: "1"
    };

    var connectMerchantJSBridge = function (callback) {
        try {
            if (window.WebViewJavascriptBridge) {
                callback(WebViewJavascriptBridge);
            } else {
                document.addEventListener("WebViewJavascriptBridgeReady", function () {
                    callback(WebViewJavascriptBridge);
                }, false);
            }
        } catch (ex) { }
    };

    var cmbMerchantBridge = {
        initSignNet: function (payData,name) {
            if (!payData) {
                payData = default_data;
            }
            connectMerchantJSBridge(function (bridge) {
                if (typeof bridge === "undefined") {
                    return;
                }
                bridge.callHandler(name, JSON.stringify(payData));
            });
        },
    };

    /*app native调用本页面方法*/
    connectMerchantJSBridge(function(bridge) {
        bridge.init(function(message, responseCallback) {

        });

        bridge.registerHandler("click1", function(data, responseCallback) {
            responseCallback("receive click1");
            /*弹窗*/
            dialog();
        });

        bridge.registerHandler("click2", function(data, responseCallback) {
            responseCallback("receive click2");
        });

         bridge.registerHandler("click3", function(data, responseCallback) {
            responseCallback("receive click3");
        });
    })


    window.cmbMerchantBridge = cmbMerchantBridge;

    function click1()
    {
        var objData = new datas();
        var payData = objData.click1;
            try {
                cmbMerchantBridge.initSignNet(payData, "initSignNetPay");
            } catch (ex) { }
    }

    function click2(){
        var objData = new datas();
        var shareData = objData.click2;

        try {
            cmbMerchantBridge.initSignNet(shareData, "initSignNetShare");
        } catch (ex) { }
    }



    /*弹窗*/
    function dialog()
    {
        click2();
    }

    <!-- 这个是本地测试方法，实际使用使用以上两个方法 -->
    function JsHandler(){
     var objData = new datas();
        var handlerData = objData.handlerData;
        cmbMerchantBridge.initSignNet(handlerData, "jsHandler1");

        cmbMerchantBridge.initSignNet(handlerData, "jsHandler2");
    }



    function datas()
    {

        this.click1 = {
            title: "hello title",
        };

        this.click2 = {
            subject : "this is title",
        };

        this.handlerData = {
            status : "ok"
        }
    }
</script>

</body>
</html>